package com.vadmin.vadminjava.servlet;


import com.alibaba.fastjson.JSONObject;
import com.vadmin.vadminjava.service.AdminWxUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/* ***********************************************************
 *
 * 这可能可能放所有和微信（包括企业微信）相关的后台业务接口
 * 但比如：卡券，比较多的话，就另起一个servlet文件
 *
 * **********************************************************/
@RestController
@RequestMapping ("/AdminWxServlet")
public class AdminWxServlet {

    @Autowired
    AdminWxUserService adminWxUserService;

    //员工列表
    @RequestMapping (value = {"/wxWorkUserList"})
    public String wxWorkUserList(@RequestParam Map<String, Object> params,HttpServletRequest httpServletRequest) {
        JSONObject paramJ = new JSONObject();
        params.keySet().forEach(i -> paramJ.put(i, params.get(i)));
        return adminWxUserService.wxWorkUserList(paramJ).toJSONString();
    }


    //外部客户列表
    @RequestMapping (value = {"/wxWorkExternalUserList"})
    public String wxWorkExternalUserList(@RequestParam Map<String, Object> params,HttpServletRequest httpServletRequest) {
        JSONObject paramJ = new JSONObject();
        params.keySet().forEach(i -> paramJ.put(i, params.get(i)));
        return adminWxUserService.wxWorkExternalUserList(paramJ).toJSONString();
    }

    //员工详情
    @RequestMapping (value = {"/userData"})
    public String userData(@RequestParam Map<String, Object> params,HttpServletRequest httpServletRequest) {
        JSONObject paramJ = new JSONObject();
        params.keySet().forEach(i -> paramJ.put(i, params.get(i)));
        return adminWxUserService.userData(paramJ).toJSONString();
    }

    //外部客户详情
    @RequestMapping (value = {"/externalUserData"})
    public String externalUserData(@RequestParam Map<String, Object> params,HttpServletRequest httpServletRequest) {
        JSONObject paramJ = new JSONObject();
        params.keySet().forEach(i -> paramJ.put(i, params.get(i)));
        return adminWxUserService.externalUserData(paramJ).toJSONString();
    }

    //员工所属外部客户列表
    @RequestMapping (value = {"/wxWorkExternalUserListOfUser"})
    public String wxWorkExternalUserListOfUser(@RequestParam Map<String, Object> params,HttpServletRequest httpServletRequest) {
        JSONObject paramJ = new JSONObject();
        params.keySet().forEach(i -> paramJ.put(i, params.get(i)));
        return adminWxUserService.wxWorkExternalUserListOfUser(paramJ).toJSONString();
    }

}
